<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

use App\DataTables\UsersDataTable;

class HomeController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(UsersDataTable $dataTable, Request $request)
    {
        $data['tasks'] = [
                [
                        'name' => 'Dashboard',
                        'progress' => '32',
                        'color' => 'success'
                ],
                [
                        'name' => 'Breadcrumbs，tooltip，original-title',
                        'progress' => '32',
                        'color' => 'success'
                ],
                [
                        'name' => 'Breadcrumbs',
                        'progress' => '32',
                        'color' => 'success'
                ],
                [
                        'name' => 'Breadcrumbs',
                        'progress' => '32',
                        'color' => 'success'
                ],
                [
                        'name' => '操作日志',
                        'progress' => '32',
                        'color' => 'success'
                ],
                [
                        'name' => 'RBAC权限',
                        'progress' => '10',
                        'color' => 'success'
                ]
        ];

        if (!empty($request->all())) {
            return $dataTable->render('admin.home');
        }

        return view('admin.home')->with($data);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }

    /**
     * Process datatables ajax request.
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function data()
    {
        $users = User::select(['id','name','email','created_at','updated_at']);

        return Datatables::of($users)->make(true);
    }
}
